<?php
/**
 * @author gray.guo
 * 
 */
namespace bc\service\base;

class Service implements IService
{
	
	public $columns = '*';
	
	public $sort = null;
	
	protected $model;
	
	
	public function getTotal($condition  = [])
	{
		return $this->model->getTotal($condition);
	}
	
	public function getList($params = array(), $page = null, $pageSize = null)
	{
		$this->model->columns = $this->columns;
		if($this->sort != null)
			$this->model->sort = $this->sort;
		return $this->model->getList($params, $page, $pageSize);
	}
	
	public function getRow($params = array())
	{
		$this->model->columns = $this->columns;
		return $this->model->getRow($params);
	}

	public function getRowById($id)
	{
		$this->model->columns = $this->columns;
		return $this->model->getRowById($id);
	}
	/**
	 *
	 * @param array $data
	 */
	public function add($data)
	{
		return $this->model->add($data);
	}
	
	/**
	 *
	 * @param array $data
	 * @param integer $id
	 */
	public function update($data, $id = null)
	{
		return $this->model->modify($data, $id);
	}
}